# Maintainer: Alexandros Theodotou <alex at zrythm dot org>

_realname=lsp-dsp-lib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.5.14
pkgrel=1
pkgdesc='SIMD-optimized library for digital signal processing'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
options=('strip' 'staticlibs' '!makeflags')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-make")
license=('LGPL3')
url="https://github.com/lsp-plugins/${_realname}"
source=("https://github.com/lsp-plugins/$_realname/releases/download/$pkgver/$_realname-$pkgver-src.tar.gz")
sha256sums=('781dae54c934bc11c412a7abbea1321e4ea6513ca24327627b8bfbe5fdb49fbd')

build() {
  cd "${srcdir}/${_realname}"

  if [[ "${MINGW_ARCH}" == *"32" ]]; then
    architecture=i586
  else
    architecture=x86_64
  fi
  make config PREFIX=${MINGW_PREFIX} ARCHITECTURE=${architecture}
  make
}

package() {
  cd "${srcdir}/${_realname}"

  make DESTDIR=${pkgdir} install
  mkdir -p "${pkgdir}${MINGW_PREFIX}/bin"
  mv "${pkgdir}${MINGW_PREFIX}/lib/"*.dll "${pkgdir}${MINGW_PREFIX}/bin"

  for file in COPYING COPYING.LESSER; do
    install -Dm644 $file "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/$file"
  done
}
